package com.ys.p1.method;

/**
 * @author CodeYang
 * @Description TODO
 * @Date 2020/12/8 21:04
 */
public class 打印水仙花数 {
    public static void main(String[] args) {
        for (int i = 100; i <= 999; i++) {
            if (isNarcissusNumber(i)){
                System.out.println("水仙花数:"+i);
            }
        }
    }

    static boolean isNarcissusNumber(int num){
     int bits = num % 10;
     int ten = num /10 %10;
//   int hundred = num /100 ;
     int hundred = num /100 %10;
     if (Math.pow(bits,3)+Math.pow(ten,3)+Math.pow(hundred,3)==num){
         return true;
     }
     return false;
    }
}
